Use case: Disable unused memory ¶
Note
When external SRAM is not needed, it is possible to disable HAL SRAM to save power.
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
|
The only option to disable SRAM is to deinitialize the HAL SRAM driver. When SRAM is needed again, the initialization sequence must be performed again. |
It is possible to disable HAL SRAM without full deinitialization when SRAM is no longer needed, and to re-enable it when the external memory is required again. |
|
|
|
/* Perform any access operation */
/* Deinitialize the SRAM */
HAL_SRAM_DeInit(&hsram);
/* Reinitialize the SRAM */
HAL_SRAM_Init(&hsram, &Sram_Timing, NULL);
/* Perform any access operation */
|
/* Perform any access operation */
/* Disable an SRAM sub-bank to save power */
HAL_SRAM_DisableMemory(&hsram);
/* Enable the corresponding SRAM sub-bank */
HAL_SRAM_EnableMemory(&hsram);
/* Perform any access operation */
|
Key changes ¶
In HAL2, SRAM can be disabled/enabled without full deinitialization.
In HAL1, disabling SRAM requires deinitializing and reinitializing the driver.

